pp108 : getFirstRow() Method

getFirstRow() Method


This method returns the row object of the first row. In case of frozen rows, the first row refers to the first frozen row.

Syntax


xgridId.getFirstRow( )

Parameters


No parameters.

Return Value


Returns a row object. For details, see row object. Returns null when the row is not found.

Remarks


One of the properties of the rowObject isrow. This property contains the HTML node of the row. However, this HTML is not always available for all rows. For some rowObjectsrowandrowFreezeColumnare null.

In combination withgetFirstRow(),getPreviousRow(),getRow(),getNextRow(), andgetLastRow(), it is possible to traverse through all the rows. All these methods return a row object that can be used as a parameter for this method.

Example


The following example demonstrates how to traverse between rows in an XGrid.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html onapplicationready="getData()">
<head>
<title>First Previous Next Last Row</title>
<script src="/cordys/wcp/application.js"></script>
<script>
function getData()
{ 
      bdiEmployees.reset();
	//bdiEmployees.data.setProperty("SelectionNamespaces", "xmlns:nwd='http://schemas.cordys.com/1.0/demo/northwind'");
     employeesGrid.bindData( bdiEmployees.data );
}
function traverse()
{
    //indices string keeps track of the visited rows
    var indices = "";
    var row = employeesGrid.getFirstRow();
    indices += row.getIndex() + " ";
    //get the next 3 rows
    for ( var i=0 ; i<3 ; i++ )
    {
        row = employeesGrid.getNextRow( row );
        indices += row.getIndex() + " ";
    }
    //get the 8th row
    row = employeesGrid.getRow(8);
    if (row)
    {
        indices += row.getIndex() + " ";
    }
    //get the last row
    row = employeesGrid.getLastRow();
     indices += row.getIndex() + " ";
    //get the 3 rows before the last row
    for ( var i=0 ; i<3 ; i++ )
    {
        row = employeesGrid.getPreviousRow( row );
        indices += row.getIndex() + " ";
    }
    application.notify(indices);
}
</script>
    <script type="cordys/xml" id="details">  
       <SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
	  <SOAP:Body>
		<GetEmployeesObjects xmlns="http://schemas.cordys.com/DemoWebServices">
		  <fromEmployeeID>1</fromEmployeeID>
		  <toEmployeeID>10</toEmployeeID>
		</GetEmployeesObjects>
	  </SOAP:Body>
</SOAP:Envelope>
     </script>
</head>
<body>
<button onclick="traverse()">Traverse rows</button>
<br/>
<br/>
<div  cordysType="wcp.library.data.BusDataIsland" async="false" id="bdiEmployees" request="details.XMLDocument"> </div>
 	 <div style="width:100%;height:100%;overflow:hidden">
        <div cordysType="wcp.library.ui.XGrid"
            id="employeesGrid" 
				xpathRowData = ".//*[local-name()='data']/*[local-name()='GetEmployeesObjectsResponse']/*[local-name()='tuple']";
                 xpathBusinessObject = ".//*[local-name()='Employees']"
            style="width:95%;height:70%">
            
            <div id="EmployeeID" ref=".//*[local-name()='EmployeeID']" dataType="integer">EmployeeID</div>
                <div id="Div1" ref=".//*[local-name()='FirstName']">FirstName</div>
               <div id="Div2" ref=".//*[local-name()='LastName']">LastName</div>
       </div>
  </div>
<br />
</body>
</html>

See Also


xgrid, getPreviousRow(), getNextRow(), getRow(), getLastRow(), row object, cell object